package com.gxc.service.impl;

import com.gxc.dao.DeptRepository;
import com.gxc.entity.Dept;
import com.gxc.service.DeptService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author GongXincheng
 * @since 2019-08-19 21:39
 */
@Service
public class DeptServiceImpl implements DeptService {
    @Resource
    private DeptRepository deptRepository;

    @Override
    public Dept find(Long id) {
        int i = 1 / 0;
        return deptRepository.findById(id).orElse(null);
    }

    @Override
    public Boolean add(Dept dept) {
        Dept entity = deptRepository.save(dept);
        return entity != null;
    }

    @Override
    public List<Dept> list() {
        return deptRepository.findAll();
    }
}
